﻿using System;
using System.Collections.Generic;
using Character;
using UnityEngine;

// Token: 0x020002BF RID: 703
internal class SelectExpressionManager
{
	// Token: 0x06001210 RID: 4624 RVA: 0x00076840 File Offset: 0x00074A40
	public void Load(TextAsset eyeF, TextAsset mouthF, TextAsset eyeM, TextAsset mouthM, TextAsset loadList)
	{
		this.setF = new ExpressionNameSet(eyeF, mouthF);
		this.setM = new ExpressionNameSet(eyeM, mouthM);
		CustomDataListLoader customDataListLoader = new CustomDataListLoader();
		customDataListLoader.Load(loadList);
		int attributeNo = customDataListLoader.GetAttributeNo("キャラ");
		int attributeNo2 = customDataListLoader.GetAttributeNo("状態");
		int attributeNo3 = customDataListLoader.GetAttributeNo("目");
		int attributeNo4 = customDataListLoader.GetAttributeNo("口");
		int attributeNo5 = customDataListLoader.GetAttributeNo("目の開き");
		int attributeNo6 = customDataListLoader.GetAttributeNo("口の開き");
		for (int i = 0; i < customDataListLoader.GetDataNum(); i++)
		{
			string data = customDataListLoader.GetData(attributeNo, i);
			string data2 = customDataListLoader.GetData(attributeNo2, i);
			string text = customDataListLoader.GetData(attributeNo3, i);
			string text2 = customDataListLoader.GetData(attributeNo4, i);
			float eyeOpen = float.Parse(customDataListLoader.GetData(attributeNo5, i)) * 0.01f;
			float mouthOpen = float.Parse(customDataListLoader.GetData(attributeNo6, i)) * 0.01f;
			if (data == "主人公" || data == "広一")
			{
				text = this.setM.EyeName(text);
				text2 = this.setM.MouthName(text2);
			}
			else
			{
				text = this.setF.EyeName(text);
				text2 = this.setF.MouthName(text2);
			}
			SelectExpressionManager.DataSet dataSet;
			if (this.dataSets.ContainsKey(data))
			{
				dataSet = this.dataSets[data];
			}
			else
			{
				dataSet = new SelectExpressionManager.DataSet(data);
				this.dataSets.Add(data, dataSet);
			}
			dataSet.Add(new SelectExpressionManager.Data(data, data2, text, eyeOpen, text2, mouthOpen));
		}
	}

	// Token: 0x06001211 RID: 4625 RVA: 0x000769F4 File Offset: 0x00074BF4
	public void Change(Human human)
	{
		string key = string.Empty;
		if (human.sex == SEX.FEMALE)
		{
			Female female = human as Female;
			key = Female.HeroineName(female.HeroineID);
			this.dataSets[key].Change(female);
		}
		else
		{
			Male male = human as Male;
			key = ((male.MaleID != MALE_ID.KOUICHI) ? "主人公" : "広一");
			this.dataSets[key].Change(male);
		}
	}

	// Token: 0x040013DF RID: 5087
	private ExpressionNameSet setF;

	// Token: 0x040013E0 RID: 5088
	private ExpressionNameSet setM;

	// Token: 0x040013E1 RID: 5089
	private Dictionary<string, SelectExpressionManager.DataSet> dataSets = new Dictionary<string, SelectExpressionManager.DataSet>();

	// Token: 0x020002C0 RID: 704
	private class Data
	{
		// Token: 0x06001212 RID: 4626 RVA: 0x00076A74 File Offset: 0x00074C74
		public Data(string chara, string state, string eyeType, float eyeOpen, string mouthType, float mouthOpen)
		{
			this.chara = chara;
			this.state = state;
			this.eyeType = eyeType;
			this.eyeOpen = eyeOpen;
			this.mouthType = mouthType;
			this.mouthOpen = mouthOpen;
		}

		// Token: 0x06001213 RID: 4627 RVA: 0x00076AAC File Offset: 0x00074CAC
		public bool Check(Female female)
		{
			string a = (!female.IsFloped()) ? "抵抗" : "豹変";
			return a == this.state;
		}

		// Token: 0x06001214 RID: 4628 RVA: 0x00076AE0 File Offset: 0x00074CE0
		public bool Check(Male male)
		{
			return true;
		}

		// Token: 0x040013E2 RID: 5090
		public string chara;

		// Token: 0x040013E3 RID: 5091
		public string state;

		// Token: 0x040013E4 RID: 5092
		public string eyeType;

		// Token: 0x040013E5 RID: 5093
		public float eyeOpen;

		// Token: 0x040013E6 RID: 5094
		public string mouthType;

		// Token: 0x040013E7 RID: 5095
		public float mouthOpen;
	}

	// Token: 0x020002C1 RID: 705
	private class DataSet
	{
		// Token: 0x06001215 RID: 4629 RVA: 0x00076AE4 File Offset: 0x00074CE4
		public DataSet(string chara)
		{
			this.chara = chara;
		}

		// Token: 0x06001216 RID: 4630 RVA: 0x00076B00 File Offset: 0x00074D00
		public void Add(SelectExpressionManager.Data data)
		{
			this.datas.Add(data);
		}

		// Token: 0x06001217 RID: 4631 RVA: 0x00076B10 File Offset: 0x00074D10
		public void Change(Female female)
		{
			List<SelectExpressionManager.Data> list = new List<SelectExpressionManager.Data>();
			for (int i = 0; i < this.datas.Count; i++)
			{
				if (this.datas[i].Check(female))
				{
					list.Add(this.datas[i]);
				}
			}
			int index = UnityEngine.Random.Range(0, list.Count);
			SelectExpressionManager.DataSet.ChangeExpression(female, list[index]);
		}

		// Token: 0x06001218 RID: 4632 RVA: 0x00076B84 File Offset: 0x00074D84
		public void Change(Male male)
		{
			List<SelectExpressionManager.Data> list = new List<SelectExpressionManager.Data>();
			for (int i = 0; i < this.datas.Count; i++)
			{
				if (this.datas[i].Check(male))
				{
					list.Add(this.datas[i]);
				}
			}
			int index = UnityEngine.Random.Range(0, list.Count);
			SelectExpressionManager.DataSet.ChangeExpression(male, list[index]);
		}

		// Token: 0x06001219 RID: 4633 RVA: 0x00076BF8 File Offset: 0x00074DF8
		private static void ChangeExpression(Human human, SelectExpressionManager.Data exp)
		{
			human.ExpressionPlay(0, exp.eyeType, 0f);
			human.ExpressionPlay(1, exp.mouthType, 0f);
			human.OpenEye(exp.eyeOpen);
			human.OpenMouth(exp.mouthOpen);
		}

		// Token: 0x040013E8 RID: 5096
		public string chara;

		// Token: 0x040013E9 RID: 5097
		public List<SelectExpressionManager.Data> datas = new List<SelectExpressionManager.Data>();
	}
}
